package com.ruoyi.Api;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.countrybus.domain.SysStation;
import com.ruoyi.project.countrybus.service.ISysStationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api("站点API")
@RestController
@RequestMapping("/api/station")
public class StationApi extends BaseController
{


    @Autowired
    private ISysStationService sysStationService;


    /**
     * 获取站点信息详细信息
     */
    @ApiOperation("通过站点Id获取站点信息")
    @GetMapping(value = "/{stationId}")
    public AjaxResult getInfo(@PathVariable("stationId") Long stationId)
    {
        return AjaxResult.success(sysStationService.selectSysStationByStationId(stationId));
    }

    /**
     * 新增站点信息
     */
    @ApiOperation("新增站点")
    @PostMapping
    public AjaxResult add(@RequestBody SysStation sysStation)
    {
        return toAjax(sysStationService.insertSysStation(sysStation));
    }

    /**
     * 修改站点信息
     */
    @ApiOperation("修改站点信息")
    @PutMapping
    public AjaxResult edit(@RequestBody SysStation sysStation)
    {
        return toAjax(sysStationService.updateSysStation(sysStation));
    }

    /**
     * 删除站点信息
     */
    @DeleteMapping("/{stationIds}")
    @ApiOperation("删除站点信息")
    public AjaxResult remove(@PathVariable Long[] stationIds)
    {
        return toAjax(sysStationService.deleteSysStationByStationIds(stationIds));
    }


    /**
     * 查询站点信息列表
     */
    @ApiOperation("查询站点信息列表")
    @GetMapping("/list")
    public TableDataInfo list(SysStation sysStation)
    {
        startPage();
        List<SysStation> list = sysStationService.selectSysStationList(sysStation);
        return getDataTable(list);
    }

}
